package com.efast.dmom.mes.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.dmom.mes.bean.ParamGroup;
import com.efast.dmom.mes.bean.ResultBean;
import com.efast.dmom.mes.entity.base.IModificationFlags;
import com.efast.dmom.mes.service.ParamGroupService;

@Controller
@RequestMapping("/paramGroup")
public class ParamGroupController {

	@Autowired
	private ParamGroupService paramGroupService;
	
	@RequestMapping(value = "/operateToBasicByParamGroup")
	public @ResponseBody ResultBean operateToBasicByParamGroup(@RequestBody ParamGroup  paramGroup) {
		if (paramGroup.getModificationFlag() == IModificationFlags.NEW) {
			return paramGroupService.save(paramGroup);
			// Judge update
		} else if (paramGroup.getModificationFlag() == IModificationFlags.MODIFIED) {
			return paramGroupService.update(paramGroup);
			// Judge to delete
		} else if (paramGroup.getModificationFlag() == IModificationFlags.DELETED) {
			return paramGroupService.delete(paramGroup);
		}
		return null;
		
	}
	@RequestMapping(value = "/deleteCheck")
	public @ResponseBody ResultBean deleteCheck(@RequestBody List<ParamGroup> listParamGroup) {
		
		return paramGroupService.deleteCheck(listParamGroup);
		
	}
}
